package com.qf.entity;

import com.qf.pojo.CheckNull;
import com.qf.pojo.CheckType;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * sys_device
 *
 * @author
 */
public class SysDevice implements Serializable, CheckNull {
    /**
     * 主键
     */
    private String deviceId;

    /**
     * 当前连接地区
     */
    private String connectLocation;

    /**
     * 在线状态 1在线,2离线
     */
    private Short isOnline;

    /**
     * 当前连接ip
     */
    private String currentConnectIp;

    /**
     * 连接时间
     */
    private Date connectTime;

    /**
     * 场景id,-1代表默认场景
     */
    private Long sceneId;

    /**
     * 绑定用户id
     */
    private Integer bindUserId;

    /**
     * 设备名字
     */
    private String deviceName;

    /**
     * 最后发送命令时间
     */
    private Date lastControlTime;

    /**
     * 断开时间
     */
    private Date lostConnectTime;

    /**
     * 绑定时间
     */
    private Date bindTime;

    /**
     * 分类id
     */
    private Integer categyId;

    private static final long serialVersionUID = 1L;

    @Override
    public boolean isEmpty(CheckType type) {
        switch (type) {
            case ADD:
              return !StringUtils.hasText(deviceId) || !StringUtils.hasText(deviceName) || ObjectUtils.isEmpty(categyId) || categyId < 0;

        }
        return CheckNull.super.isEmpty(type);
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getConnectLocation() {
        return connectLocation;
    }

    public void setConnectLocation(String connectLocation) {
        this.connectLocation = connectLocation;
    }

    public Short getIsOnline() {
        return isOnline;
    }

    public void setIsOnline(Short isOnline) {
        this.isOnline = isOnline;
    }

    public String getCurrentConnectIp() {
        return currentConnectIp;
    }

    public void setCurrentConnectIp(String currentConnectIp) {
        this.currentConnectIp = currentConnectIp;
    }

    public Date getConnectTime() {
        return connectTime;
    }

    public void setConnectTime(Date connectTime) {
        this.connectTime = connectTime;
    }

    public Long getSceneId() {
        return sceneId;
    }

    public void setSceneId(Long sceneId) {
        this.sceneId = sceneId;
    }

    public Integer getBindUserId() {
        return bindUserId;
    }

    public void setBindUserId(Integer bindUserId) {
        this.bindUserId = bindUserId;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public Date getLastControlTime() {
        return lastControlTime;
    }

    public void setLastControlTime(Date lastControlTime) {
        this.lastControlTime = lastControlTime;
    }

    public Date getLostConnectTime() {
        return lostConnectTime;
    }

    public void setLostConnectTime(Date lostConnectTime) {
        this.lostConnectTime = lostConnectTime;
    }

    public Date getBindTime() {
        return bindTime;
    }

    public void setBindTime(Date bindTime) {
        this.bindTime = bindTime;
    }

    public Integer getCategyId() {
        return categyId;
    }

    public void setCategyId(Integer categyId) {
        this.categyId = categyId;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SysDevice other = (SysDevice) that;
        return (this.getDeviceId() == null ? other.getDeviceId() == null : this.getDeviceId().equals(other.getDeviceId()))
                && (this.getConnectLocation() == null ? other.getConnectLocation() == null : this.getConnectLocation().equals(other.getConnectLocation()))
                && (this.getIsOnline() == null ? other.getIsOnline() == null : this.getIsOnline().equals(other.getIsOnline()))
                && (this.getCurrentConnectIp() == null ? other.getCurrentConnectIp() == null : this.getCurrentConnectIp().equals(other.getCurrentConnectIp()))
                && (this.getConnectTime() == null ? other.getConnectTime() == null : this.getConnectTime().equals(other.getConnectTime()))
                && (this.getSceneId() == null ? other.getSceneId() == null : this.getSceneId().equals(other.getSceneId()))
                && (this.getBindUserId() == null ? other.getBindUserId() == null : this.getBindUserId().equals(other.getBindUserId()))
                && (this.getDeviceName() == null ? other.getDeviceName() == null : this.getDeviceName().equals(other.getDeviceName()))
                && (this.getLastControlTime() == null ? other.getLastControlTime() == null : this.getLastControlTime().equals(other.getLastControlTime()))
                && (this.getLostConnectTime() == null ? other.getLostConnectTime() == null : this.getLostConnectTime().equals(other.getLostConnectTime()))
                && (this.getBindTime() == null ? other.getBindTime() == null : this.getBindTime().equals(other.getBindTime()))
                && (this.getCategyId() == null ? other.getCategyId() == null : this.getCategyId().equals(other.getCategyId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getDeviceId() == null) ? 0 : getDeviceId().hashCode());
        result = prime * result + ((getConnectLocation() == null) ? 0 : getConnectLocation().hashCode());
        result = prime * result + ((getIsOnline() == null) ? 0 : getIsOnline().hashCode());
        result = prime * result + ((getCurrentConnectIp() == null) ? 0 : getCurrentConnectIp().hashCode());
        result = prime * result + ((getConnectTime() == null) ? 0 : getConnectTime().hashCode());
        result = prime * result + ((getSceneId() == null) ? 0 : getSceneId().hashCode());
        result = prime * result + ((getBindUserId() == null) ? 0 : getBindUserId().hashCode());
        result = prime * result + ((getDeviceName() == null) ? 0 : getDeviceName().hashCode());
        result = prime * result + ((getLastControlTime() == null) ? 0 : getLastControlTime().hashCode());
        result = prime * result + ((getLostConnectTime() == null) ? 0 : getLostConnectTime().hashCode());
        result = prime * result + ((getBindTime() == null) ? 0 : getBindTime().hashCode());
        result = prime * result + ((getCategyId() == null) ? 0 : getCategyId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", deviceId=").append(deviceId);
        sb.append(", connectLocation=").append(connectLocation);
        sb.append(", isOnline=").append(isOnline);
        sb.append(", currentConnectIp=").append(currentConnectIp);
        sb.append(", connectTime=").append(connectTime);
        sb.append(", sceneId=").append(sceneId);
        sb.append(", bindUserId=").append(bindUserId);
        sb.append(", deviceName=").append(deviceName);
        sb.append(", lastControlTime=").append(lastControlTime);
        sb.append(", lostConnectTime=").append(lostConnectTime);
        sb.append(", bindTime=").append(bindTime);
        sb.append(", categyId=").append(categyId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
